import axios from "axios";
import _axios from "./request"
// axios.defaults.baseURL = 'http://1.94.210.234:8080/api';
//所属行业列表
export const getIndustryById = (id) => {
    return _axios.get('/common/industry/' + id)
};
//经营地址
export const address = (id) => {
    return _axios.get('/common/region/' + id).then(response => {
        // 处理服务器响应
        return response.data;
    }).catch(error => {
        // 处理错误
        this.$message.error('获取经营地址信息失败:', error);
        throw error;
    });
};
//密码登录
export const MimaLogin = (phone, password) => {
    return _axios.post('/user/loginByPasswd', {
        phone: phone,
        password: password
    }
    )
}
//获取验证码
export const Yanzhang = (phone) => {
    return _axios.get('user/sendRegisterCode/' + phone
    )
}
//注册
export const Zhuce = (bodyName, unifyCreditCode, phone, password, code) => {
    return _axios.post('/user/register', {
        bodyName: bodyName,
        unifyCreditCode: unifyCreditCode,
        phone: phone,
        password: password,
        code: code,
    })
}
//手机号校验
function isPhoneNumber(phone) {
    // 正则表达式用于匹配手机号格式
    var phoneRegex = /^1[3-9]\d{9}$/;
    if (phoneRegex.test(phone)) {
        return true;
    } else {
        return false;
    }
}
export { isPhoneNumber };
//统一信用社会代码验证
function iscode(daima) {
    var codeRegex = /^[0-9A-HJ-NPQRTUWXY]{2}\d{6}[0-9A-HJ-NPQRTUWXY]{10}$/;
    if (codeRegex.test(daima)) {
        return true;
    } else {
        return false;
    }
}
export { iscode }

//邮箱校验
function isEmail(managerEmail) {
    var pattern = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if (pattern.test(managerEmail)) {
        return true;
    } else {
        return false
    }
}
export { isEmail };
//获取修改密码验证码
export const UpdateYanZheng = (updatePhone) => {
    return _axios.get('user/sendForgetCode/' + updatePhone)
}

// 忘记密码
export const ForgetPassword = (phone, password, code) => {
    return _axios.post('/user/forgetPassword', {
        phone: phone,
        password: password,
        code: code
    })
}
//登出
export const Dengchu = () => {
    return _axios.get('user/logout')
}
//验证码登录
export const YanzhangLogin = (phone, code) => {
    return _axios.post('/user/loginByCode/', {
        phone: phone,
        code: code
    })
}
//获取登录验证码
export const DengluYanzhang = (phone) => {
    return _axios.get('/user/sendLoginCode/' + phone
    )
}
//企业维护
export const QiyeWeihu = ((data) => {
    return _axios.put('/auth/maintenance', data)
})
//获取企业信息维护
export const HuoquQiyeWeihu = (() => {
    return _axios.get('/auth/maintenance')
})
// 获取认证信息（通过登录的用户id或认证信息id）
export const HuoQuRenZheng = (() => {
    return _axios.get('/auth')
})

//修改认证信息
export const XiuGaiRenZheng = (data) => {
    return _axios.put('/auth', data)
}
//提交认证信息
export const TiJiaoRenZheng = (data) => {
    return _axios.post('/auth', data)
}
//删除认证信息
export const DELETERenZheng = (id, token) => {
    return _axios.delete('/auth/' + id, {
        headers: {
            'Content-Type': 'multipart/form-data',
            'Authorization': `Bearer ${token}` // 假设您使用的是 Bearer 令牌
        }
    })
}
//个人信息展示
export const GeRenXinXi = (id) => {
    return _axios.get('/user/' + id)
}
//文章接口
export const Wenzhang = (pageSize, pageNumber, categoryId) => {
    return _axios.post('/article/list', {
        pageSize: pageSize,
        pageNumber: pageNumber,
        categoryId: categoryId
    })
}


// 项目列表
export const ProgictList = (pageSize, pageNumber, projectName, categoryId, code) => {
    return _axios.post('/project/list', {
        pageSize: pageSize,
        pageNumber: pageNumber,
        projectName: projectName,
        categoryId: categoryId,
        code: code
    })
}

// 根据ID来获取项目信息
export const ProgictById = (id) => {
    return _axios.get('/project/' + id)
}

//增加项目浏览量
export const AddViews = (id) => {
    return _axios.put('/project/updateView/' + id)
}

// 项目需求发布
export const XuqiuFaBu = ((queryFaBu) => {
    return _axios.post('/project/add', queryFaBu)
})
//新闻列表
export const NewstList = (pageSize, pageNumber, categoryId) => {
    return _axios.post('/article/list', {
        pageSize: pageSize,
        pageNumber: pageNumber,
        categoryId: categoryId
    })
}
//联系我们
export const Contact = () => {
    return _axios.get('/contact/list', {
    })
}
//合作机构图片
export const institution = () => {
    return _axios.get('institutions/list', {
    })
}
//根据id获取新闻
export const newsById = (id) => {
    return _axios.get('/article/list/' + id)
}

//获取角色列表
export const roleList = () => {
    return _axios.get('/role/1', { params: {} })
}

//获取服务机构列表
export const brandList = (RoleQuery) => {
    return _axios.get('/userDetail/list', {
        params: RoleQuery
    })
}

//根据userId查看机构详情
export const brandDetails = (userId) => {
    return _axios.get(`/auth?userId=${userId}`)
}

// 查询个人项目信息
export const QueryInformation = () => {
    return _axios.get('/project/myselfProject')
}
// 修改项目信息
export const reviseInformation = (data) => {
    return _axios.put('/project/update', data)
}
// 删除项目
export const deleteInformation = (id) => {
    return _axios.delete('/project/delete/' + id)
}

// 获取行业名称
export const industryName = (indus) => {
    return _axios.post('/common/detail', {
        indus: indus
    })
}
// 获取地址名称
export const businessAddressName = (address) => {
    return _axios.post('/common/addressDeatil', {
        address: address
    })
}
//机构详情新闻列表
export const JigouNewsList = (query) => {
    return _axios.get('/news/list', {
        params: query
    })
}
//新闻发布
export const addNews = ((body) => {
    return _axios.post('/news/addNews', body)
})
//根据id获取机构的新闻详情
export const JigouNesById = (id) => {
    return _axios.get('/news/getNews/' + id)
}
// 修改项目信息
export const reviseNews = (data) => {
    return _axios.put('/news/updateNews', data)
}
//删除新闻
export const deleteNews = (id) => {
    return _axios.delete('/news/deleteNews/' + id)
}
//在地图上获取信息
export const getmap = ()=>{
    return _axios.get('exchanges/list')
}